package com.design.consumer.p02;

import java.util.concurrent.TimeUnit;

/**
 * 
 * 生产者线程
 *
 */
public class Producer implements Runnable {

	/**
	 * 
	 * 每次生产的产品数量
	 * 
	 */
	private int num;

	private Storage storage;

	public Producer(Storage s) {
		this.storage = s;
	}

	@Override
	public void run() {
		while (true) {
			this.storage.produce(num);
			try {
				TimeUnit.SECONDS.sleep(2);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}

	}

	public int getNum() {
		return num;
	}

	public void setNum(int num) {
		this.num = num;
	}

	public Storage getStorage() {
		return storage;
	}

	public void setStorage(Storage storage) {
		this.storage = storage;
	}

}
